package com.example.demo.demos.test;

import com.example.demo.demos.web.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

@RequestMapping("/return")
@RestController
public class ReturnValue {
    @RequestMapping("/f1")
    public String f1(){
        return "/f1.html";
    }
    @RequestMapping("/f2")
    public User f2(){
        User user = new User();
        user.setAge(18);
        user.setName("lisi");
        return user;
    }
    @ResponseBody
    @RequestMapping("/f3")
    public String f3(){
        return "<h1>f3方法</h1>";
    }
    @RequestMapping("/f4")
    public Map<String, String> f4(){
        Map<String, String> map = new HashMap<>();
        map.put("A","1");
        map.put("B","2");
        map.put("C","3");
        return map;
    }
    @RequestMapping("/f5")
    public Set<String> f5(){
        Set<String> set = new HashSet<>();
        set.add("A");
        set.add("B");
        set.add("C");
        return set;
    }
    @RequestMapping("/f7")
    public int[] f7(){
        return new int[]{1,2,3};
    }
    @RequestMapping(value = "/f6", produces = "application/json;charset=utf8")
    public String f6(){
        return "{'Ok':1}";
    }

}
